//
//  DealHistoryVC.m
//  HengYouCai
//
//  Created by ycgwl on 2017/5/3.
//  Copyright © 2017年 lwj. All rights reserved.
//

#import "DealHistoryVC.h"
#import "DealAllViewController.h"
#import "HengYouCai-Swift.h"
@interface DealHistoryVC ()<PageTitleViewDelegate,PageContentViewDelegate>

@end

@implementation DealHistoryVC

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    self.title = self.titleName;
    self.titleH = 40;
    self.intervalH = 10;
    self.titles = [NSMutableArray array];
    self.contents = [NSMutableArray array];
    [self getTradeTypeList];
}
- (void)getTradeTypeList{
    
    WLGetWeakSelf(weakSelf, self);
    [self.view showHUDLoading];
    [HYCNetService getMyWalletaTradeDetailTypeListOnSuccess:^(NSDictionary *dictResult) {
        
        [weakSelf.view hideHUDLoading:0];
        NSArray *arr = dictResult[@"cdkeyTypeList"];
       
        for (NSDictionary *typeDic in arr) {
            DealAllViewController *vc = [[UIStoryboard storyboardWithName:@"Profile" bundle:nil] instantiateViewControllerWithIdentifier:@"DealAllViewControllerID"];
            vc.statusType = typeDic[@"type"];
            
            [self.contents addObject:vc];
            [self.titles addObject:typeDic[@"title"]];
        }
        [self setUI];
    } andFailed:^(NSInteger code, NSString *errorMsg) {
          [weakSelf.view showHUDFailTips:errorMsg hideDelay:kHUDHideDelay];
    }];
    
    
}
/**
 初始化界面
 */
- (void)setUI
{
    self.view.backgroundColor = Normal_BackColor;
    self.automaticallyAdjustsScrollViewInsets = NO;
    [self.view addSubview:self.pageTitleView];
    [self.view addSubview:self.pageContentView];
}
#pragma PageTitleViewDelegate
- (void)pageTitleView:(PageTitleView *)titleView selectedIndex:(NSInteger)index
{
    [_pageContentView setCurrentIndex:index];
}
#pragma PageContentViewDelegate

- (void)pageContentView:(PageContentView *)contentView progress:(CGFloat)progress sourceIndex:(NSInteger)sourceIndex targetIndex:(NSInteger)targetIndex
{
    [_pageTitleView setTitleWithProgress:progress sourceIndex:sourceIndex targetIndex:targetIndex];
}
#pragma 懒加载
- (PageTitleView *)pageTitleView
{
    if (!_pageTitleView) {
        
        /**
         标题栏
         */
        _pageTitleView = [[PageTitleView alloc] initWithFrame:CGRectMake(0, kJcwGetNavHeight(), f_Device_w, _titleH) titles:self.titles];
        _pageTitleView.delegate = self;
        _pageTitleView.backgroundColor = [UIColor whiteColor];
    }
    return _pageTitleView;
}
- (PageContentView *)pageContentView
{
    if (!_pageContentView) {
        /**
         内容
         */
        CGRect rect = CGRectMake(0, kJcwGetNavHeight()+_titleH+_intervalH, f_Device_w, f_Device_h-(kJcwGetNavHeight()+_titleH+_intervalH));
        
        _pageContentView = [[PageContentView alloc] initWithFrame:rect childVcs:_contents parentViewController:self];
        _pageContentView.delegate = self;
    }
    return _pageContentView;
}


@end
